package proxyTest.server;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.EventLoop;
import io.netty.channel.SimpleChannelInboundHandler;

import java.util.concurrent.TimeUnit;

/**
 * @Author: jia
 * @Descirption:
 * @Date: 2018/5/16 14:06
 * @Modified By:
 */


public class ServerHandler extends SimpleChannelInboundHandler {
    @Override
    protected void channelRead0(final ChannelHandlerContext ctx, Object o) throws Exception {
        System.out.println("服务端收到的消息===" + o);
        EventLoop eventLoop = ctx.channel().eventLoop();
        eventLoop.schedule(new Runnable() {
            @Override
            public void run() {
                ctx.channel().writeAndFlush("你好,我是服务器！");
            }
        }, 5, TimeUnit.SECONDS);

    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        super.channelActive(ctx);
    }
}
